package tn.orange.canreminder.sort;

import java.util.Comparator;
import java.util.Date;
import java.util.List;

import tn.orange.canreminder.model.Competition;
import tn.orange.canreminder.model.Country;
import tn.orange.canreminder.singleton.CountrySingleton;
import tn.orange.canreminder.utils.DateUtils;

public class CompetitionComparator implements Comparator<Competition> {

	List<Country> countries = CountrySingleton.getInstance();

	@Override
	public int compare(Competition cmp1, Competition cmp2) {

		int result = 0;
		Date date1 = DateUtils.stringToDate(cmp1.getCompetitiondate());
		Date date2 = DateUtils.stringToDate(cmp2.getCompetitiondate());

		if (date1.compareTo(date2) < 0) {
			result = -1;
		} else
			return 1;

		return result;

	}
}